var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: []
  },
  backto: function (e) {
    wx.navigateBack({})
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
    const token = extConfig.appid;
    that.setData({
      shop_id: options.shop_id,
      wid: options.wid,
      openid: app.globalData.openid,
      token: token
    })
    app.ihttpGet('https://www.58zltc.com/api.php/Shop/getClerks/openid/' + app.globalData.openid + '/wid/' + that.data.wid, function (res) {
      that.setData({
        clerks: res.data
      })
    })
  },
  delClerk: function (e) {
    var that = this
    app.ihttpGet('https://www.58zltc.com/api.php/Shop/getClerks/mid/' + e.currentTarget.dataset.mid, function (res) {
      var title = ''
      var icon = 'none'
      if (res.data == '1') {
        title = '移除成功'
        icon = 'success'
      } else {
        title = '网络忙或已移除'
      }
      wx.showToast({
        title: title,
        icon: icon,
        duration: 1200
      })
      setTimeout(function () {
        app.ihttpGet('https://www.58zltc.com/api.php/Shop/getClerks/openid/' + app.globalData.openid + '/wid/' + that.data.wid, function (res) {
          that.setData({
            clerks: res.data
          })
        })
      }, 1200)
    })
  }

})